#ifndef SERVERMANAGER_H
#define SERVERMANAGER_H

#include "Singleton.h"
#include "ServerSocket.h"
#include "ClientSocket.h"
#include "GameMessage.h"

#include <D3DX10.h>
#include <string>

class ServerManager : public Uncopyable
{
	ServerManager();
	friend class Singleton<ServerManager>;
public:
	bool Open(int port);
	ServerSocket& GetSocket();
	Socket* Accept();
	void AddClient(ClientSocket* cs);
	bool SendGameMessageToAll(GameMessage& gm);

	void CheckPing();
	bool GetIsServer() const;
	void SetClientPosition(int clientID, const D3DXVECTOR3& pos);
	ClientSocket& GetClient(int id) const;
private:
	ServerSocket m_sock;
	bool m_isServer;
};

typedef Singleton<ServerManager> TheServerManager;

#endif //SERVERMANAGER_H